package cn.broadsense.thrid.param;

import cn.broadsense.common.exception.ServiceException;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 设备云台的转动
 *
 * @author pengxin
 * @date 2022-08-10 11:38
 */
@ApiModel("设备云台的转动")
@Data
public class VideoCloudTurnParam extends BaseParam {
    private static final long serialVersionUID = 4735408606067743593L;

    @ApiModelProperty("通道编码")
    private String channelId;

    @ApiModelProperty("持续时间")
    private Integer duration;

    @ApiModelProperty("x:水平控制速度相对值(-1, 1) x>0为右转，反之左转")
    private Double pan;

    @ApiModelProperty("y:垂直控制速度相对值(-1, 1) y>0向上转，反之向下转")
    private Double tilt;

    @ApiModelProperty("z:变倍控制速度相对值(-1, 1) zoom>0为放大，反之缩小")
    private Double zoom;

    @Override
    public void checkParam() {
        if (StrUtil.isBlank(channelId)) {
            throw new ServiceException("通道id不能为空");
        }
        if (pan == null) {
            throw new ServiceException("x:水平控制不能为空");
        }
        if (tilt == null) {
            throw new ServiceException("y:垂直控制不能为空");
        }
        if (zoom == null) {
            throw new ServiceException("z:变倍控制不能为空");
        }
    }

    @Override
    public Class getResultClass() {
        return String.class;
    }
}
